package cn.wolfcode.business.controller;

import cn.wolfcode.business.domain.vo.StatementItemVO;
import cn.wolfcode.business.service.IBusStatementItemService;
import cn.wolfcode.common.core.controller.BaseController;
import cn.wolfcode.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 结算单明细Controller
 * 
 * @author wolfcode
 * @date 2025-09-23
 */
@RestController
@RequestMapping("/business/item")
public class BusStatementItemController extends BaseController
{
    @Autowired
    private IBusStatementItemService busStatementItemService;

    /**
     * 保存功能
     * @param vo 结算单折扣价   结算单明细集合
     * @return 结果
     */
    @PostMapping
    public AjaxResult statementItemSave(@RequestBody StatementItemVO vo) {
        return toAjax(busStatementItemService.statementItemSave(vo));
    }

    /**
     * 根据结算单 Id 查询结算单明细列表
     * @param statementId 结算单id
     * @return 结算单明细集合
     */
    @GetMapping
    public AjaxResult getStatementItemList(Long statementId){
        return AjaxResult.success(busStatementItemService.selectList(statementId));
    }

    /**
     * 结算单支付功能
     * @param statementId 结算单 id
     * @return 结果
     */
    @PatchMapping("/{statementId}")
    public AjaxResult pay(@PathVariable Long statementId){
        return toAjax(busStatementItemService.pay(statementId));
    }

}
